package create.factory;

import create.factory.factoryMethod.AppleComputerFactory;
import create.factory.factoryMethod.HuaWeiComputerFactory;
import create.factory.simpleFactory.IComputer;

/**
 * @author dali
 * @date 2021-07-09 11:40
 * @Description 工厂方法
 */

public class FactoryMethodTest {
    public IComputer getService(String type) {
        IComputer service = null;
        if ("shallow".equals(type)) {
            HuaWeiComputerFactory aFactory = new HuaWeiComputerFactory();
            service = aFactory.getService();
        }
        if ("B".equals(type)) {
            AppleComputerFactory bFactory = new AppleComputerFactory();
            service = bFactory.getService();
        }
        //生产电脑
        service.method();
        return service;
    }
}
